<?php $__env->startSection('content'); ?>

    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商品品牌</strong> / <small>Good Brands</small></div>
            </div>

            <hr>

           <?php if(session('brand')): ?>
                <div class="am-g">
                    <div class="am-u-md-12">
                        <div class="am-alert am-alert-success">
                            <?php echo e(session('brand')); ?>

                        </div>
                    </div>
                </div>
               <?php endif; ?>

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="<?php echo e(route('shop.brand.create')); ?>"  class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</a>
                        </div>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <form action="<?php echo e(route('shop.brand.index')); ?>" method="get" >
                        <?php /*<?php echo csrf_field(); ?>*/ ?>
                    <div class="am-input-group am-input-group-sm">

                            <input type="text" name="keyword" class="am-form-field">
                              <span class="am-input-group-btn" >
                                <button  class="am-btn am-btn-default" type="submit" >搜索</button>
                              </span>

                    </div>
                    </form>
                </div>
            </div>

            <div class="am-g">
                <div class="am-u-sm-12">
                    <?php /*<form class="am-form">*/ ?>
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                            <tr>
                                <th class="table-id">ID</th>
                                <th class="table-thumb">缩略图</th>
                                <th class="table-name">品牌名称</th>
                                <th>品牌商品</th>
                                <th class="table-desc">品牌描述</th>
                                <th class="table-is-show am-hide-sm-only">是否显示</th>
                                <th class="table-sort-order am-hide-sm-only" style="width:10%">排序</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach($brands as $brand): ?>
                            <tr data-id="<?php echo e($brand->id); ?>">

                                <td><?php echo e($brand->id); ?></td>
                                <td>
                                    <?php if($brand->thumb): ?><img src="<?php echo e($brand->thumb); ?>" alt class="thumb" style="height: 60px"><?php endif; ?>
                                </td>
                                <td><?php echo e($brand->name); ?></td>
                                <td class="am-hide-sm-only">商品-预留</td>
                                <td class="am-hide-sm-only"><?php echo e($brand->desc); ?></td>
                                <td class="am-hide-sm-only">
                                   <?php /* <span class="<?php echo e($brand->is_show==0?'am-icon-close':'am-icon-check'); ?> is_something" data-attr="is_show"></span>*/ ?>
                                    <?php echo is_show('is_show',$brand); ?>

                                </td>
                                <td class="am-hide-sm-only">
                                    <input type="text" name="sort_order" class="am-input-sm" value="<?php echo e($brand->sort_order); ?>">
                                </td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a href="<?php echo e(route('shop.brand.edit',[$brand->id])); ?>" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>

                        <form action="<?php echo e(route('shop.brand.destroy',[$brand->id])); ?>" method="post" style="float: left;display: inline">
                            <?php echo csrf_field(); ?>

                            <?php echo method_field('delete'); ?>

                            <button  type="submit" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="return confirm('确定要删除吗')" ><span class="am-icon-trash-o"></span> 删除</button>
                        </form>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                           <?php endforeach; ?>
                            </tbody>
                        </table>


                        <div class="am-cf" style="float: right">

                            <?php echo $brands->appends(Request::all())->links(); ?>


                        </div>
                        <hr />
                        <p>共<?php echo e($brands->total()); ?>条记录</p>


                </div>

            </div>
        </div>

        <footer class="admin-content-footer">
            <hr>
            <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
        </footer>

    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <?php /*<script src="laravel.js"></script>*/ ?>
 <script>

     $(function(){

         /*$.ajaxSetup({
             headers: {
                 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
             }
         });*/


         //是否显示
         $('.is_something').click(function(){
             var _this=$(this);
             id=$(this).parents("tr").attr('data-id');
             $.ajax({
                 url:"<?php echo e(url('/shop/brand/is_show')); ?>",
                 type:'patch',
                 data:{id:id},
                 success:function (data) {
                     console.log(data);
                     _this.toggleClass('am-icon-close am-icon-check');
                 }
             });
         })


         //排序
         $("input[name='sort_order']").change(function () {
             var data = {
                 sort_order: $(this).val(),
                 id: $(this).parents("tr").attr('data-id')
             }

             $.ajax({
                 type: "patch",
                 url:"<?php echo e(url('/shop/brand/sort_order')); ?>",
                 data: data,
             });
         })


     })
 </script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>